package cn.boysoft.module.security.model.entity;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Type;

import com.fasterxml.jackson.annotation.JsonIgnore;

import cn.boysoft.core.annotation.JEEEntityDeclare;
import cn.boysoft.core.model.entity.BaseEntity;

@Table(name="jee_role")
@Entity
@JEEEntityDeclare(name="角色信息")
public class RoleEntity extends BaseEntity {
	@Column(length=36)
	private String name;
	@Column(length=255)
	private String remark;
	@Type(type="yes_no")
	private Boolean admin = false;
	
	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @JoinTable(name = "jee_role_resource", joinColumns = {
    @JoinColumn(name = "roleId")}, inverseJoinColumns = {
    @JoinColumn(name = "resourceId")})
    @JsonIgnore
	Set<ResourceEntity> resources;
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public Boolean getAdmin() {
		return admin;
	}
	public void setAdmin(Boolean admin) {
		this.admin = admin;
	}
	public Set<ResourceEntity> getResources() {
		return resources;
	}
	public void setResources(Set<ResourceEntity> resources) {
		this.resources = resources;
	}
	
}
